import webview
from io import StringIO
from pywebview_flask import app
from contextlib import redirect_stdout

def on_closing(window):
    def closeing():
        window.destroy()
    return closeing

if __name__ == '__main__':
    stream = StringIO()
    with redirect_stdout(stream):
        window = webview.create_window('My first pywebview application', app)
        window.closing += on_closing(window)
        webview.start(debug=True)